﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace storeSMS
{
    public partial class frmReSMS : Form
    {
        public frmReSMS()
        {
            InitializeComponent();
        }

        private void frmReSMS_Load(object sender, EventArgs e)
        {
            
            SMSMessage.Read();
            dgvsendinfo.AutoGenerateColumns = false;
            Bind();
        }

        

        private void btnOK_Click(object sender, EventArgs e)
        {
            Bind();
        }

        private void Bind()
        {
            string gys = txtgys.Text.Trim();
            string phone = txtphone.Text.Trim();
            string project = txtproject.Text.Trim();
            string ddh = txtddh.Text.Trim();
            string sql = "";
            if (gys != "")
                sql += " and gys='" + gys + "'";
            if (phone != "")
                sql += " and phone='" + phone + "'";
            if (ddh != "")
                sql += " and cgddh='" + ddh + "'";
            if (project != "")
                sql += " and project='" + project + "'";
            BLL.reinfo bll = new BLL.reinfo();
            DataSet ds = bll.GetList(sql);
            dgvsendinfo.DataSource = ds.Tables[0];
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int rowindex = 0;
            rowindex = dgvsendinfo.CurrentRow.Index;            
            int sid = 0;
            string  phone = "", recontent = "";
            phone = dgvsendinfo.Rows[rowindex].Cells["phone"].Value.ToString();
            recontent = dgvsendinfo.Rows[rowindex].Cells["recontent"].Value.ToString();
            sid = int.Parse(dgvsendinfo.Rows[rowindex].Cells["ID"].Value.ToString());
            BLL.reinfo b = new BLL.reinfo();
            if (MessageBox.Show("确定要删除信息：" + phone + "：" + recontent + "吗？", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                b.Delete(sid);
                Bind();
            }
        }
    }
}
